#include <stdio.h>
#include <stdlib.h>

#define ERROR NULL
typedef int ElementType;
typedef struct LNode *PtrToLNode;
struct LNode {
    ElementType Data;
    PtrToLNode Next;
};
typedef PtrToLNode Position;
typedef PtrToLNode List;

Position Find( List L, ElementType X ){
    while (L != NULL){
        if(L->Data == X){
            return L;// 找到元素，返回节点指针
        }
        L=L->Next;
    }
    return ERROR;// 找不到元素，返回ERROR
}
List Insert( List L, ElementType X, Position P ){
    PtrToLNode newNode = (PtrToLNode) malloc(sizeof(struct LNode));
    newNode->Data=X;
    newNode->Next = NULL;
    //特殊情况：插入到头部
    if(P == L || L == NULL){
        newNode->Next = L;
        return newNode;
    }
    // 寻找插入位置的前一个节点
    PtrToLNode current = L;
    while (current->Next != P){
        if(current->Next == NULL){
            printf("Wrong Position for Insertion\n");
            return ERROR;
        }
        current = current->Next;
    }
    current->Next = newNode;
    newNode->Next = P;
    return L; // 返回链表头
}
List Delete( List L, Position P ){
    if(P == NULL){
        printf("Wrong Position for Deletion\n");
        return ERROR;
    }
    if(L == P){
        PtrToLNode current = L;
        L = L->Next;
        free(current);
        return L;
    }
    PtrToLNode current = L;
    while (current->Next != P){
        if(current->Next==NULL){
            printf("Wrong Position for Deletion\n");
            return ERROR;
        }
        current = current->Next;
    }
    current->Next = P->Next;
    free(P);
    return L;
}

int main()
{
    List L;
    ElementType X;
    Position P, tmp;
    int N;

    L = NULL;
    scanf("%d", &N);
    while ( N-- ) {
        scanf("%d", &X);
        L = Insert(L, X, L);
        if ( L==ERROR ) printf("Wrong Answer\n");
    }
    scanf("%d", &N);
    while ( N-- ) {
        scanf("%d", &X);
        P = Find(L, X);
        if ( P == ERROR )
            printf("Finding Error: %d is not in.\n", X);
        else {
            L = Delete(L, P);
            printf("%d is found and deleted.\n", X);
            if ( L==ERROR )
                printf("Wrong Answer or Empty List.\n");
        }
    }
    L = Insert(L, X, NULL);
    if ( L==ERROR ) printf("Wrong Answer\n");
    else
        printf("%d is inserted as the last element.\n", X);
    P = (Position)malloc(sizeof(struct LNode));
    tmp = Insert(L, X, P);
    if ( tmp!=ERROR ) printf("Wrong Answer\n");
    tmp = Delete(L, P);
    if ( tmp!=ERROR ) printf("Wrong Answer\n");
    for ( P=L; P; P = P->Next ) printf("%d ", P->Data);
    return 0;
}

/* 你的代码将被嵌在这里 */